<?php
class PrioritiesController extends AppController {

	var $name = 'Priorities';
	
	function beforeFilter(){
		$this->belepesCheck();
	}

	function index() {
		$this->pageTitle = W2D . ELV . PRIORITIES;
		$this->Priority->recursive = 0;
		$this->set('priorities', $this->Priority->findAll());
	}

	function add() {
		$this->pageTitle = W2D . ELV . PRIORITIES;
		if (empty($this->data)) {
			$this->render();
		} else {
			$this->cleanUpFields();
			if ($this->Priority->save($this->data)) {
				$this->Session->setFlash('The Priority has been saved');
				$this->redirect('/priorities/index');
			} else {
				$this->Session->setFlash('Please correct errors below.');
			}
		}
	}

	function edit($id = null) {
		$this->pageTitle = W2D . ELV . PRIORITIES;
		if (empty($this->data)) {
			if (!$id) {
				$this->Session->setFlash('Invalid id for Priority');
				$this->redirect('/priorities/index');
			}
			$this->data = $this->Priority->read(null, $id);
		} else {
			$this->cleanUpFields();
			if ($this->Priority->save($this->data)) {
				$this->Session->setFlash('The Priority has been saved');
				$this->redirect('/priorities/index');
			} else {
				$this->Session->setFlash('Please correct errors below.');
			}
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash('Invalid id for Priority');
			$this->redirect('/priorities/index');
		}
		if ($this->Priority->del($id)) {
			$this->Session->setFlash('The Priority deleted: id '.$id.'');
			$this->redirect('/priorities/index');
		}
	}

}
?>